import { CITY_DATA } from '@/store/mutation-types'
import { checkNumber,checkPhoneOrLandline} from '@/utils/util'

export const PARAMS_RISE = [
   {
        type: "RangePicker",
        field: "day",
        title: "日期",
        value: [],
        props: {
            type: "daterange",
            valueFormat: "YYYY-MM-DD",
            "start-placeholder":"开始日期",
            "end-placeholder":"结束日期",
        },
        emit: ['change'],
        emitPrefix: 'btn-time',
    },
    {
      type:'a-button',
      field:'search',
      props:{
          type:'primary',
          icon:"search"
      },
      children:['搜索'],
      emit: ['click'],
      emitPrefix: 'btn-search',
    },
    {
      type:'a-button',
      field:'reset',
      props:{
          type:'primary',
          icon:"setting"
      },
      children:['重置'],
      emit: ['click'],
      emitPrefix: 'btn-reset',
    },
] 

export const FORM_RISE = [
    {
        type: "a-input",
        field: "bankName",
        title: "开户行",
        value: '',
        props: { type: "text"},
        validate: [
            { required: true, message: "请输入开户行", trigger: "blur" }
        ]
    },
    {
        type: "a-input",
        field: "accountNo",
        title: "银行账号",
        value: "",
        props: { type: "text",maxLength:30},
        validate: [
            { required: true, message: "请输入银行账号", trigger: "blur" },
            {
                validator: (rule, val, d) => {
                val && !checkNumber(val) ? d(true) : d();
            },
            message: "银行卡号格式有误"
            }
        ]
    },
     {
        type: "a-input",
        field: "mobile",
        title: "电话",
         value: "",
        props: { type: "text",placeholder: "请输入联系方式",maxLength:15},
        validate: [
            { required: true, message: "请输入联系方式", trigger: "blur" },
            {
                message: "电话格式错误"
            }
        ]
    },
     {
        type: "radio",
        field: "appoint",
        title: "是否默认",
         value: 1,
        options:[{value:1,label:'是'},{value:2,label:'否'}],
    },
    {
       type:"a-textarea",
       field:"address",
       title:"地址",
       value: "",
        props: {  style: "width:100%;",autoSize:{ minRows: 5}},
       validate: [
            { required: true, message: "请输入地址", trigger: "blur" }
        ]
    }
]

export const PARAMS_MAIL = [
    {
        type: "a-input",
        field: "name",
        title: "收件人姓名",
        value: "",
        props: {placeholder:"请输入收件人姓名"}
    },
    {
        type: "a-input",
        field: "mobile",
        title: "收件人电话",
        value: "",
        props: {placeholder:"请输入收件人电话"}
    },
   {
        type: "RangePicker",
        field: "day",
        title: "日期",
        value: [],
        props: {
            type: "daterange",
            valueFormat: "YYYY-MM-DD",
            "start-placeholder":"开始日期",
            "end-placeholder":"结束日期",
        },
        emit: ['change'],
        emitPrefix: 'btn-time',
    },
    {
      type:'a-button',
      field:'search',
      props:{
          type:'primary',
          icon:"search"
      },
      children:['搜索'],
      emit: ['click'],
      emitPrefix: 'btn-search',
    },
    {
      type:'a-button',
      field:'reset',
      props:{
          type:'primary',
          icon:"setting"
      },
      children:['重置'],
      emit: ['click'],
      emitPrefix: 'btn-reset',
    },
] 

export const FORM_MAIL = [
    {
        type: "a-input",
        field: "name",
        title: "收件人姓名",
        value: '',
        props: { type: "text"},
        validate: [
            { required: true, message: "请输入收件人姓名", trigger: "blur" }
        ]
    },
     {
        type: "a-input",
        field: "mobile",
        title: "收件人电话",
         value: "",
        props: { type: "text",placeholder: "请输入收件人电话",maxLength:11},
        validate: [
            { required: true, message: "请输入收件人电话", trigger: "blur" },
            {
            validator: (rule, val, d) => {
                val && !/^1(3[0-9]|4[0-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-9])\d{8}$/.test(val) ? d(true) : d();
            },
            message: "手机格式错误"
            }
        ]
    },
    {
        type:"cascader",
        title:"所在区域",
        field:"area",
        value: [],
        props:{
            options:CITY_DATA
        },
        validate: [
            { required: true, message: "请选择区域", trigger: "change" }
        ]
    },
    {
        type: "radio",
        field: "appoint",
        title: "是否默认",
         value: 1,
        options:[{value:1,label:'是'},{value:2,label:'否'}],
    },
    {
       type:"a-textarea",
       field:"address",
       title:"详细地址",
       value: "",
        props: {  style: "width:100%;",autoSize:{ minRows: 5}},
       validate: [
            { required: true, message: "请输入详细地址", trigger: "blur" }
        ]
    }
]

export const COLUMNS_RISE = [
     {
        title: '企业名称',
        dataIndex: 'enterpriseName',
        scopedSlots: { customRender: 'enterpriseName' }
    },
    {
        title: '纳税人识别号',
        dataIndex: 'creditCode',
        scopedSlots: { customRender: 'creditCode' }
    },
    {
        title: '地址',
        dataIndex: 'address',
        scopedSlots: { customRender: 'address' }
    },
    {
        title: '电话',
        dataIndex: 'mobile',
    },
    {
        title: '开户行',
        dataIndex: 'bankName',
        scopedSlots: { customRender: 'bankName' }
    },
    {
        title: '银行账号',
        dataIndex: 'accountNo',
        scopedSlots: { customRender: 'accountNo' }
    },
    {
        title: '是否默认',
        dataIndex: 'appoint',
        scopedSlots: { customRender: 'appoint' }
    },
     {
        title: '创建时间',
        dataIndex: 'createdTime',
    },
    {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' }
    }
];


export const COLUMNS_MAIL = [
     {
        title: '收件人姓名',
        dataIndex: 'name'
    },
    {
        title: '收件人电话',
        dataIndex: 'mobile',
    },
    {
        title: '省份',
        dataIndex: 'province',
        customRender: (text, row, index) => {
            const province = CITY_DATA.find(v => v.value === row.province);
            if (province) {
                return province.label
            }
            return '--'
        },
    },
    {
        title: '城市',
        dataIndex: 'city',
        customRender: (text, row, index) => {
            const cityObj = CITY_DATA.find(product =>product.children.find(item =>
                item.value === row.city
            ));
            if (cityObj && cityObj.children) {
                return cityObj.children[0].label;
            }
            return '--'
        },
    },
    {
        title: '县（区）',
        dataIndex: 'area',
        customRender: (text, row, index) => {
            const cityObj = CITY_DATA.find(product =>product.children.find(item =>
                item.value === row.city
            ));
            if (cityObj) {
                const children = cityObj.children[0].children;
                const areaObj = children.find(product => product.value === row.area);
                if (areaObj) {
                    return areaObj.label;
                }
            }
            return '---'
        },
    },
    {
        title: '详细地址',
        dataIndex: 'address',
    },
    {
        title: '是否为默认地址',
        dataIndex: 'appoint',
        scopedSlots: { customRender: 'appoint' }
    },
     {
        title: '创建时间',
        dataIndex: 'createdTime',
    },
    {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' }
    }
];

export const PARAMS_BILLING = [
   {
        type: "a-input",
        field: "name",
        title: "企业名称",
        value: '',
        props: {
            type: "text",
            placeholder:'请输入名称'
        }
    },
    {
      type:'a-button',
      field:'search',
      props:{
          type:'primary',
          icon:"search"
      },
      children:['搜索'],
      emit: ['click'],
      emitPrefix: 'btn-search',
    },
    {
      type:'a-button',
      field:'reset',
      props:{
          type:'primary',
          icon:"setting"
      },
      children:['重置'],
      emit: ['click'],
      emitPrefix: 'btn-reset',
    }
] 

export const PARAMS_BILLING_DETAIL = [
   {
        type: "DatePicker",
        field: "time",
        title: "月份",
        value: '',
        props: {
            type: "month",
            dateFormat: "YYYY-MM",
        }
    },
    {
        type: "a-input",
        field: "batchCode",
        title: "结算批次编号",
        value: '',
        props: {
            type: "text",
            placeholder:'结算批次编号'
        }
    },
    {
        type: "a-input",
        field: "batchName",
        title: "结算批次名称",
        value: '',
        props: {
            type: "text",
            placeholder:'结算批次名称'
        }
    },
    {
      type:'a-button',
      field:'search',
      props:{
          type:'primary',
          icon:"search"
      },
      children:['搜索'],
      emit: ['click'],
      emitPrefix: 'btn-search',
    },
    {
      type:'a-button',
      field:'reset',
      props:{
          type:'primary',
          icon:"setting"
      },
      children:['重置'],
      emit: ['click'],
      emitPrefix: 'btn-reset',
    },
    {
      type:'a-button',
        field: 'back',
      class:'ant-btn-warning',
      props:{
          icon:"logout"
      },
      children:['返回'],
      emit: ['click'],
      emitPrefix: 'btn-back',
    }
] 

export const COLUMNS_BILLING_COMANY = [
     {
        title: '关联园区名称',
        dataIndex: 'parkName',
        scopedSlots: { customRender: 'parkName' },
        width:140
    },
    {
        title: '当月开票次数',
        dataIndex: 'monthCount',
    },
    {
        title: '当月开票总额（元）',
        dataIndex: 'monthAmount',
        customRender: (text, row, index) => {
            if (row.monthAmount) {
                return '¥' + row.monthAmount
            } 
            return ''
        },
    },
    {
        title: '历史开票次数',
        dataIndex: 'totalCount',
    },
    {
        title: '历史开票总额（元）',
        dataIndex: 'totalAmount',
        customRender: (text, row, index) => {
            if (row.totalAmount) {
                return '¥' + row.totalAmount
            } 
            return ''
        },
    },
    {
        title: '未开票总额（元）',
        dataIndex: 'noneAmount',
        customRender: (text, row, index) => {
            if (row.noneAmount) {
                return '¥' + row.noneAmount
            } 
            return ''
        },
    },
    {
        title: '可开票总额（元）',
        dataIndex: 'allowAmount',
        customRender: (text, row, index) => {
            if (row.allowAmount) {
                return '¥' + row.allowAmount
            } 
            return ''
        },
    },
    {
        title: '待审核开票金额（元）',
        dataIndex: 'waitAuditAmount',
        customRender: (text, row, index) => {
            if (row.waitAuditAmount) {
                return '¥' + row.waitAuditAmount
            } 
            return ''
        },
    },
    {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' }
    }
];
export const COLUMNS_BILLING_PARK = [
     {
        title: '企业名称',
        dataIndex: 'enterpriseName',
        scopedSlots: { customRender: 'enterpriseName' },
        width:140
    },
    {
        title: '当月开票次数',
        dataIndex: 'monthCount',
    },
    {
        title: '当月开票总额（元）',
        dataIndex: 'monthAmount',
        customRender: (text, row, index) => {
            if (row.monthAmount) {
                return '¥' + row.monthAmount
            } 
            return ''
        },
    },
    {
        title: '历史开票次数',
        dataIndex: 'totalCount',
    },
    {
        title: '历史开票总额（元）',
        dataIndex: 'totalAmount',
        customRender: (text, row, index) => {
            if (row.totalAmount) {
                return '¥' + row.totalAmount
            } 
            return ''
        },
    },
    {
        title: '未开票总额（元）',
        dataIndex: 'noneAmount',
        customRender: (text, row, index) => {
            if (row.noneAmount) {
                return '¥' + row.noneAmount
            } 
            return ''
        },
    },
    {
        title: '可开票总额（元）',
        dataIndex: 'allowAmount',
        customRender: (text, row, index) => {
            if (row.allowAmount) {
                return '¥' + row.allowAmount
            } 
            return ''
        },
    },
    {
        title: '待审核开票金额（元）',
        dataIndex: 'waitAuditAmount',
        customRender: (text, row, index) => {
            if (row.waitAuditAmount) {
                return '¥' + row.waitAuditAmount
            } 
            return ''
        },
    },
    {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' }
    }
];
export const COLUMNS_BILLING_ADMIN = [
     {
        title: '企业名称',
        dataIndex: 'enterpriseName',
        scopedSlots: { customRender: 'enterpriseName' },
        width:140
    },
     {
        title: '关联园区名称',
         dataIndex: 'parkName',
         scopedSlots: { customRender: 'parkName' },
        width:140
    },
    {
        title: '当月开票次数',
        dataIndex: 'monthCount',
    },
    {
        title: '当月开票总额（元）',
        dataIndex: 'monthAmount',
        customRender: (text, row, index) => {
            if (row.monthAmount) {
                return '¥' + row.monthAmount
            } 
            return ''
        },
    },
    {
        title: '历史开票次数',
        dataIndex: 'totalCount',
    },
    {
        title: '历史开票总额（元）',
        dataIndex: 'totalAmount',
        customRender: (text, row, index) => {
            if (row.totalAmount) {
                return '¥' + row.totalAmount
            } 
            return ''
        },
    },
    {
        title: '未开票总额（元）',
        dataIndex: 'noneAmount',
        customRender: (text, row, index) => {
            if (row.noneAmount) {
                return '¥' + row.noneAmount
            } 
            return ''
        },
    },
    {
        title: '可开票总额（元）',
        dataIndex: 'allowAmount',
        customRender: (text, row, index) => {
            if (row.allowAmount) {
                return '¥' + row.allowAmount
            } 
            return ''
        },
    },
    {
        title: '待审核开票金额（元）',
        dataIndex: 'waitAuditAmount',
        customRender: (text, row, index) => {
            if (row.waitAuditAmount) {
                return '¥' + row.waitAuditAmount
            } 
            return ''
        },
    },
    {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' }
    }
];

export const COLUMNS_NO_BILLING = [
     {
        title: '结算日期',
        dataIndex: 'settleTimeSubmit'
    },
     {
        title: '批次编号',
        dataIndex: 'settleBatchCode'
    },
    {
        title: '结算批次名称',
        dataIndex: 'settleBatchName',
    },
    {
        title: '结算状态',
        dataIndex: 'settleStatus',
        customRender: (text, row, index) => {
            if (row.settleStatus === 1) {
                return '待审核'
            } else if (row.settleStatus === 2){
                return '结算中'
            } else if (row.settleStatus === 3){
                return '结算成功'
            } else if (row.settleStatus === 4){
                return '部分结算成功'
            } else if (row.settleStatus === 5){
                return '结算失败'
            } else if (row.settleStatus === 6){
                return '已驳回'
            } 
            return '--'
        },
    },
    {
        title: '任务类型',
        dataIndex: 'taskType',
        customRender: (text, row, index) => {
            if (row.taskType === 1) {
                return '线上'
            } else if (row.taskType === 2){
                return '线下'
            } 
            return '--'
        },
    },
    {
        title: '任务编号',
        dataIndex: 'taskId',
    },
    {
        title: '任务名称',
        dataIndex: 'taskName',
    },
    {
        title: '结算金额',
        dataIndex: 'settleAmount',
        customRender: (text, row, index) => {
            if (row.settleAmount) {
                return '¥' + row.settleAmount
            } 
            return ''
        },
    },
    {
        title: '服务费',
        dataIndex: 'parkServiceAmount',
        customRender: (text, row, index) => {
            if (row.parkServiceAmount) {
                return '¥' + row.parkServiceAmount
            } 
            return ''
        },
    },
    {
        title: '开票总金额',
        dataIndex: 'invoiceAmount',
        customRender: (text, row, index) => {
            if (row.invoiceAmount) {
                return '¥' + row.invoiceAmount
            } 
            return ''
        },
    },
    {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' }
    }
];

export const COLUMNS_OTHER_BILLING = [
     {
        title: '发票申请编号',
        dataIndex: 'invoiceId'
    },
     {
        title: '任务类型',
         dataIndex: 'taskType',
        customRender: (text, row, index) => {
            if (row.taskType === 1) {
                return '线上'
            } else if (row.taskType === 2){
                return '线下'
            } 
            return '--'
        },
    },
    {
        title: '状态更新时间',
        dataIndex: 'updatedTime',
    },
    {
        title: '包含批次数量',
        dataIndex: 'total',
    },
    {
        title: '发票类型',
        dataIndex: 'type',
        customRender: (text, row, index) => {
            if (row.type === 1) {
                return '增值税普通发票'
            } else if (row.type === 2){
                return '增值税电子普票发票'
            } else if (row.type === 3){
                return '增值税专用发票'
            } else if (row.type === 4){
                return '增值税电子专用发票'
            } 
            return '--'
        },
    },
    {
        title: '开票金额',
        dataIndex: 'amount',
        customRender: (text, row, index) => {
            if (row.amount) {
                return '¥' + row.amount
            } 
            return ''
        },
    },
    {
        title: '开票类目',
        dataIndex: 'category'
    },
    {
        title: '开票状态',
        dataIndex: 'status',
        customRender: (text, row, index) => {
            if (row.status === 1) {
                return '已开票'
            } else if (row.status === 2){
                return '待审核'
            } else if (row.status === 3){
                return '待开票'
            } else if (row.status === 4){
                return '驳回'
            } else if (row.status === 5){
                return '作废'
            } 
            return '--'
        },
    },
    {
        title: '备注',
        dataIndex: 'remark',
    },
    {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' }
    }
];

export const COLUMNS_BATCH = [
     {
        title: '结算编号',
        dataIndex: 'settleBatchCode'
    },
     {
        title: '结算批次名称',
        dataIndex: 'settleBatchName'
    },
    {
        title: '结算金额',
        dataIndex: 'settleSuccessAmount',
        customRender: (text, row, index) => {
            if (row.settleSuccessAmount) {
                return '¥' + row.settleSuccessAmount
            } 
            return ''
        },
    }
]

export const EN_BILLING_TAB = [
    { key: '-1', tab: '未开票'},
    { key: '2', tab: '待审核'},
    { key: '3', tab: '待开票'},
    { key: '1', tab: '已开票'},
    { key: '4', tab: '已驳回'}
]
export const PARK_BILLING_TAB = [
    { key: '2', tab: '待审核'},
    { key: '3', tab: '待开票'},
    { key: '1', tab: '已开票'},
    { key: '4', tab: '已驳回'}
]

 export const OPTION_INLINE = {
    form: {layout: 'inline'},
    resetBtn: false,
    submitBtn: false
  }
  export const OPTION_BLOCK= {
    form: { layout: "vertical" },
    row:{gutter: 20},
    resetBtn: false,
    submitBtn: false
  }
 